<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp" %>
<title>Insert title here</title>
</head>
<body>
<fieldset class="layui-elem-field" style="margin:20px;padding:15px">
  <legend>添加信息</legend>
    <form  class="layui-form " lay-filter="formA" method="post" >
    	<div class="layui-form-item">
    	<label class="layui-form-label">员工姓名</label>
    	<div class="layui-input-inline">
      		<select name="codeEmp"></select>
    	</div>
 		</div>
 	
    	<div class="layui-form-item">
    	<label class="layui-form-label">项目名称</label>
    	<div class="layui-input-inline">
      		<select name="codePro"></select>
    	</div>
 		</div>
 		
 		<div class="layui-form-item">
    	<label class="layui-form-label">绩效</label>
    	<div class="layui-input-inline">
      		<select name="score"></select>
    	</div>
 		</div>
 		
 		<div class="layui-form-item">
 		<label class="layui-form-label"></label>
    	<div class="layui-input-block">
      		<input type="button" class="layui-btn" lay-submit lay-filter="add" value="确定" >
    		<input type="button" class="layui-btn" onclick="layerClose()" value="关闭" >
    	</div>
 		</div>
 		
 		<input type="hidden" name="action" value="add" >
    	
    </form>
</fieldset>

<script type="text/javascript">

initSel();

function initSel(){//从数据库取回下拉框中的数据
	 ajax("/EmployeeServlet",{action:"list"},'json',function(data){
		 var opt = "<option value=''>请选择员工</option>"
			$.each(data,function(){
				opt +="<option value='"+this.code+"'>"+this.name+"</option>"
			})
			$("select[name='codeEmp']").html(opt);
		 form.render();
		})
		
		ajax("/ProjectServlet",{action:"list"},'json',function(data){
			 var opt = "<option value=''>请选择项目</option>"
				$.each(data,function(){
					opt +="<option value='"+this.code+"'>"+this.name+"</option>"
				})
				$("select[name='codePro']").html(opt);
			 form.render();
			})
			
	var obj = [10,20,30,40,50,60,70,80,90,100];
	 var opt = "<option value=''>请选择绩效</option>"
	 $.each(obj,function(i){
		 opt +="<option value='"+obj[i]+"'>"+obj[i]+"</option>"
	 })
	 $("select[name='score']").html(opt);
 }
  
	 
 
 
 formOnSubmit('add','/ScoreServlet','text',function(data){
		console.log(data)
		if(data==1){
				layer.msg("添加成功",{time:1500},layerClose)
			}else if(data=="repeat"){
				layer.msg("添加失败，记录重复")
			}else{
				layer.msg("添加失败")
			}
	})
 


</script>

</body>
</html>